/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "exercice")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Exercice.findAll", query = "SELECT e FROM Exercice e"),
    @NamedQuery(name = "Exercice.findByIdexercice", query = "SELECT e FROM Exercice e WHERE e.idexercice = :idexercice"),
    @NamedQuery(name = "Exercice.findByTitre", query = "SELECT e FROM Exercice e WHERE e.titre = :titre"),
    @NamedQuery(name = "Exercice.findByDescription", query = "SELECT e FROM Exercice e WHERE e.description = :description")})
public class Exercice implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "idexercice")
    private String idexercice;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "titre")
    private String titre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10000)
    @Column(name = "description")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "exercice")
    private Collection<TdExo> tdExoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "exercice")
    private Collection<ExoContenu> exoContenuCollection;
    @JoinColumn(name = "idauteur", referencedColumnName = "idutilisateur")
    @ManyToOne(optional = false)
    private Utilisateur idauteur;
    @OneToMany(mappedBy = "idcorrection")
    private Collection<Exercice> exerciceCollection;
    @JoinColumn(name = "idcorrection", referencedColumnName = "idexercice")
    @ManyToOne
    private Exercice idcorrection;

    public Exercice() {
    }

    public Exercice(String idexercice) {
        this.idexercice = idexercice;
    }

    public Exercice(String idexercice, String titre, String description) {
        this.idexercice = idexercice;
        this.titre = titre;
        this.description = description;
    }

    public String getIdexercice() {
        return idexercice;
    }

    public void setIdexercice(String idexercice) {
        this.idexercice = idexercice;
    }

    public String getTitre() {
        return titre;
    }

    public void setTitre(String titre) {
        this.titre = titre;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public Collection<TdExo> getTdExoCollection() {
        return tdExoCollection;
    }

    public void setTdExoCollection(Collection<TdExo> tdExoCollection) {
        this.tdExoCollection = tdExoCollection;
    }

    @XmlTransient
    public Collection<ExoContenu> getExoContenuCollection() {
        return exoContenuCollection;
    }

    public void setExoContenuCollection(Collection<ExoContenu> exoContenuCollection) {
        this.exoContenuCollection = exoContenuCollection;
    }

    public Utilisateur getIdauteur() {
        return idauteur;
    }

    public void setIdauteur(Utilisateur idauteur) {
        this.idauteur = idauteur;
    }

    @XmlTransient
    public Collection<Exercice> getExerciceCollection() {
        return exerciceCollection;
    }

    public void setExerciceCollection(Collection<Exercice> exerciceCollection) {
        this.exerciceCollection = exerciceCollection;
    }

    public Exercice getIdcorrection() {
        return idcorrection;
    }

    public void setIdcorrection(Exercice idcorrection) {
        this.idcorrection = idcorrection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idexercice != null ? idexercice.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Exercice)) {
            return false;
        }
        Exercice other = (Exercice) object;
        if ((this.idexercice == null && other.idexercice != null) || (this.idexercice != null && !this.idexercice.equals(other.idexercice))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.Exercice[ idexercice=" + idexercice + " ]";
    }
    
}
